;; If the game is paused, then move the snake left.
;; If the game is already paused, move the snake one square.
(defun my/snake-move-up ()
  (interactive)
  (if snake-paused
      (progn
        (snake-pause-game)
        (snake-move-up)
        (snake-update-game "*Snake*")
        (snake-pause-game))
    (progn
      (snake-move-up)
      (snake-update-game "*Snake*")
      (snake-pause-game))))

(defun my/snake-move-down ()
  (interactive)
  (if snake-paused
      (progn
        (snake-pause-game)
        (snake-move-down)
        (snake-update-game "*Snake*")
        (snake-pause-game))
    (progn
      (snake-move-down)
      (snake-update-game "*Snake*")
      (snake-pause-game))))

(defun my/snake-move-left ()
  (interactive)
  (if snake-paused
      (progn
        (snake-pause-game)
        (snake-move-left)
        (snake-update-game "*Snake*")
        (snake-pause-game))
    (progn
      (snake-move-left)
      (snake-update-game "*Snake*")
      (snake-pause-game))))

(defun my/snake-move-right ()
  (interactive)
  (if snake-paused
      (progn
        (snake-pause-game)
        (snake-move-right)
        (snake-update-game "*Snake*")
        (snake-pause-game))
    (progn
      (snake-move-right)
      (snake-update-game "*Snake*")
      (snake-pause-game))))

;; call a new snake game and in some new keybindings
(defun my/snake ()
  (interactive)
  (define-key snake-mode-map (kbd "t") 'my/snake-move-down)
  (define-key snake-mode-map (kbd "c") 'my/snake-move-up)
  (define-key snake-mode-map (kbd "h") 'my/snake-move-left)
  (define-key snake-mode-map (kbd "n") 'my/snake-move-right)
  (snake))
